#pragma once

#include "Component.h"

#include <list>

class Composite : public Component
{
protected:
    std::list<Component *> m_children;

public:
    void add(Component *component)
    {
        m_children.push_back(component);
        component->setParent(this);
    }

    void remove(Component *component)
    {
        m_children.remove(component);
        component->setParent(nullptr);
    }

    void operation()
    {
        for (Component *c : m_children) {
            c->operation();
        }
    }
};